#include "uart.h"
#include "string.h"
#include "task.h"
#include "list.h"
#include <stdio.h>
#include "sem.h"
static char stack_a[1024] __attribute__ ((aligned (4)));
static char stack_b[1024] __attribute__ ((aligned (4)));
static char stack_c[1024] __attribute__ ((aligned (4)));
sem_t sem;
//void task_a(void *param)
//{
//    char c = (char)param;
//    while (1)
//    {
//        putchar(c);
//    }
//}

//int mymain()
//{
//    task_list_init();  
//    create_task(task_a, (void*)'a', stack_a, 1024, 2, "TaskA");
//    create_task(task_a, (void*)'b', stack_b, 1024, 1, "TaskB");
//    create_task(task_a, (void*)'c', stack_c, 1024, 1, "TaskC");
//    start_task();
//    return 0;
//}


void task_a(void *param) {
    while (1) {
        sem_get(&sem);  
        putchar('A');
    }
}


void task_b(void *param) {
    while (1) {
        
       //   for (int i = 0; i < 100; i++);
        sem_post(&sem);  
    }
}

int mymain() {
    task_list_init();
    sem_init(&sem, 0);  
    
    create_task(task_a, NULL, stack_a, 1024, 2, "TaskA"); 
    create_task(task_b, NULL, stack_b, 1024, 2, "TaskB");
    
    start_task();
    return 0;
}